package com.crm.task.beans;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import org.apache.log4j.Logger;

public class CrmStream extends Thread {
	
	private static Logger logger = Logger.getLogger(CrmStream.class);
	
	InputStream is;  
    String type;
          
    public CrmStream(InputStream is, String type) {  
        this.is = is;  
        this.type = type;  
    }   
      
    public void run() {  
        InputStreamReader isr = null;  
        BufferedReader br = null;  
        try {                   
            isr = new InputStreamReader(is);  
            br = new BufferedReader(isr);  
            String line=null;  
            while ( (line = br.readLine()) != null) {  
            	logger.info(type + " >>> " + line);
            }  
        } catch (IOException ioe) {  
            ioe.printStackTrace();    
        } finally{  
        	try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
        	try {
				isr.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
        }  
    }  
}
